from Products.KnowledgeEngine.KERL.Tokens.Token import Token
from Products.KnowledgeEngine.Services.MySQLFiveAssessmentStorageService.MySQLFiveAssessmentStorageService import qstr

class StringToken(Token):
    
    def __init__(self, object, namespace):
        if type(object) is not str:
            raise "Creating StringToken with non-string value %s" % `object`
        
        Token.__init__( self, object, namespace )
    
    def toEnglish(self):
        """ Compiles this token into english """
        
        return self.object

    def toSQL(self, quote="'"):
        """ Compiles this token into SQL """
        
        return qstr(self.object, quote=quote)

    def toJavascript(self):
        
        return qstr(self.getObject())

    def toKERL(self):
        return qstr(self.getObject())


    def __str__(self):
        return self.getObject()